import { relogin } from '@/api'
//home模块的仓库
const state = {
  username: ''
  //home仓库中存储三级菜单的数据
}
//mutions是唯一修改state的地方
const mutations = {
  USERNAME(state, username) {
    state.username = username
  },
  LOGIN(state, username) {
    state.username = username
  }
}
//action|用户处理派发action地方的，可以书写异步语句、自己逻辑地方
const actions = {
  async saveUserName(context, username) {
    context.commit('USERNAME', username)
  },
  // eslint-disable-next-line no-unused-vars
  async login({ commit }, data) {
    let result = await relogin(data)
    console.log(result)
    alert(result.msg)
    commit('LOGIN', result.data.username)
  }
}
//计算属性
const getters = {}
export default {
  state,
  mutations,
  actions,
  getters
}
